﻿using System;
using System.Windows;
using DataController;
using DataController.Controllers;
using LockerRack.Exceptions;

namespace DropBoxToDoWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private const string ROOT_FOLDER = @"d:\mine\sources\desktop\DropBoxToDo_codeplex\TestFileController\TestData\Locker";
        private ITaskController Controller
        {
            get { return TaskModelController.GetInstance(); }
        }

        public MainWindow()
        {
            InitializeComponent();
            Exception ex;
            CreateLocker(out ex);
            if (ex == null)
                PopulateTasks();
        }

        private void PopulateTasks()
        {
            
        }

        private void CreateLocker(out Exception exception)
        {
            try
            {
                LockerException ex;
                Controller.Initialize(ROOT_FOLDER, out ex);
                exception = ex;
            }
            catch (Exception eex)
            {
                exception = eex;
            }
        }

        private void CloseController(bool saveOnClose, out Exception exception)
        {
            try
            {
                LockerException ex;
                Controller.Clear(saveOnClose, out ex);
                exception = ex;
            }
            catch (Exception eex)
            {
                exception = eex;
            }
        }
    }
}
